﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Extensions;

public partial class Search : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        ProductListVertical1.Title = Request.QueryString["q"];
        BLL.MenuManager mManager = new BLL.MenuManager();
        XMLMenu.Data = mManager.BuildXMLMenu("setSearchCategory").ToString();
    }

    protected void SearchButton_Click(object sender, EventArgs e)
    {
        HttpRequest request = Request;
        string url = Page.GetQueryStringNavigateUrl("catId", CategoryIdField.Value, request);
        request = new HttpRequest("Search.aspx", Request.Url.ToString(), GetQueryString(url));
        Response.Redirect(Page.GetQueryStringNavigateUrl("q", ProductTitleSearchField.Text, request));
    }

    private string GetQueryString(string url)
    {
        return url.Substring(url.IndexOf("?") + 1);
    }
}
